﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows;
using System.Windows.Controls;
using HMI.Header;

namespace HMI.Tool
{
    public class Msgbox
    {
        public static void Show(Window window, string title, string msg, Action<bool> ac)
        {
            MsgboxFrm ls = new MsgboxFrm();
            ls.DEvent = new Action<bool>((bool bl) =>
            {
                if (ac != null)
                    ac(bl);
            });
            ls.WindowStartupLocation = WindowStartupLocation.Manual;
            Point mousePos = window.PointToScreen(Mouse.GetPosition(window));
            ls.Left = mousePos.X;
            ls.Top = mousePos.Y;
            ls.LabelTxt = title;
            ls.TxtContent = msg;
            ls.ShowDialog();
        }
        public static void Show(UserControl window, string title, string msg, Action<bool> ac)
        {
            MsgboxFrm ls = new MsgboxFrm();
            ls.DEvent = new Action<bool>((bool bl) =>
            {
                if (ac != null)
                    ac(bl);
            });
            ls.WindowStartupLocation = WindowStartupLocation.Manual;
            Point mousePos = window.PointToScreen(Mouse.GetPosition(window));
            ls.Left = mousePos.X;
            ls.Top = mousePos.Y;
            ls.LabelTxt = title;
            ls.TxtContent = msg;
            ls.ShowDialog();
        }
        public static void ShowCenter(Window window, string title, string msg, Action<bool> ac)
        {
            MsgboxFrm ls = new MsgboxFrm();
            ls.DEvent = new Action<bool>((bool bl) =>
            {
                if (ac != null)
                    ac(bl);
            });
            ls.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            ls.LabelTxt = title;
            ls.TxtContent = msg;
            ls.ShowDialog();
        }
        public static void ShowCenter(UserControl window, string title, string msg, Action<bool> ac)
        {
            MsgboxFrm ls = new MsgboxFrm();
            ls.DEvent = new Action<bool>((bool bl) =>
            {
                if (ac != null)
                    ac(bl);
            });
            ls.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            ls.LabelTxt = title;
            ls.TxtContent = msg;
            ls.ShowDialog();
        }
    }
}
